/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package projetosustentabilidade;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import connectionBD.retornoBD;
import java.awt.Color;
import java.util.ArrayList;

import javax.swing.JFrame;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.LogarithmicAxis;
import org.jfree.chart.axis.NumberAxis;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.data.xy.XYSeries;
import org.jfree.data.xy.XYSeriesCollection;

public class GraficoLinear extends JFrame {

    private ArrayList<retornoBD> objExcel;
    private int[] anos = {1981, 1986, 1991, 1996, 2001, 2006};

    public GraficoLinear(ArrayList<retornoBD> objArquivo) {
        objExcel = objArquivo;
    }

    class XYLogAxesDemo extends JFrame {

        public XYLogAxesDemo(final String title) {


            super(title);


            //Criacao das varios curvas do grafico
            final XYSeriesCollection dataset = new XYSeriesCollection();
            for (Integer k = 0; k < anos.length; k++) {
                final XYSeries s1 = new XYSeries("Nome País (" + k.toString() + ")");
                for (int i = 0; i < objExcel.getObjTaxas().size(); i++) {

                    s1.add(anos[k], objExcel.getObjTaxas().get(i).getInterv01());

                }
                dataset.addSeries(s1);



            }




            final JFreeChart chart = ChartFactory.createXYLineChart(
                    "Atributo Nome (F) x Tempo (Hz)", // chart title
                    "Value", // domain axis label
                    "Value", // range axis label
                    dataset, // data
                    PlotOrientation.VERTICAL,
                    true, // include legend
                    true,
                    false);
            final XYPlot plot = chart.getXYPlot();
            final NumberAxis domainAxis = new NumberAxis("Anos (Hz)");
            final NumberAxis rangeAxis = new NumberAxis("Atributo Nome (F)");

            plot.setDomainAxis(domainAxis);

            plot.setRangeAxis(rangeAxis);

            chart.setBackgroundPaint(Color.WHITE);
            //chart.clearSubtitles();

            plot.setOutlinePaint(Color.black);
            final ChartPanel chartPanel = new ChartPanel(chart);

            chartPanel.setPreferredSize(new java.awt.Dimension(500, 270));
            setContentPane(chartPanel);

        }
    }
}
